<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>新增链接</title>
    <link rel="stylesheet" href="/static/css/font.css">
    <link rel="stylesheet" href="/static/css/index.css">
    <script src="/static/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/static/js/index.js"></script>


</head>
<body>

<div class="layui-card">
    <form class="layui-form layui-form-pane" action="" id="add">
        <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
            <ul class="layui-tab-title">
                <li class="layui-this">基本信息</li>
            </ul>

            <div class="layui-tab-content" >
                <div class="layui-tab-item layui-show">
                    <div class="layui-form-item">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>链接名称
                        </label>
                        <div class="layui-input-block">
                            <input type="text" name="linkName" id="linkName"  autocomplete="off"
                                   class="layui-input">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>链接地址
                        </label>
                        <div class="layui-input-block">
                            <input type="text" name="linkUrl" id="linkUrl" autocomplete="off"
                                   class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <button class="layui-btn" type="button" lay-filter="add" lay-submit="" onclick="add()">
                            保存
                        </button>
                    </div>
                    <!--</form>-->
                    <div style="height:100px;"></div>
                </div>
            </div>

        </div>
    </form>
</div>

<script type="text/javascript">
    function add() {
        var linkName = $("#linkName").val();
        var linkUrl = $("#linkUrl").val();
        $.ajax({
            url: 'toAddLink',
            method: 'post',
            async: false,
            data: {
                'linkName': linkName,
                'linkUrl': linkUrl,
            },
            success: function (data) {
                res = data;
                // alert(res)
            }
        });
        if (res == "1") {
            location.reload();
        } else {
            window.location.href = "toErrorPage"
        }
    }
</script>
</body>
</html>